package com.example.demo;

import com.example.demo.controller.WebController;
import com.example.demo.dao.DepartmentMapper;
import com.example.demo.dto.Department;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);

        /**
         * jdk8
         * ::
         * 对象::实例方法名
         * 类::静态方法
         * 类::实例方法
         */
        // stream  过滤与切片
//        System.out.print("----------------------------------过滤与切片--------------------------------");
//        int[] age = {13, 23, 32, 42, 54, 65, 76};
//        System.out.print("过滤-----------------------------------------------------\n");
//        Arrays.stream(age).filter(e -> e > 32).forEach(System.out::println);
//        System.out.print("去重-----------------------------------------------------\n");
//        Arrays.stream(age).distinct().forEach(System.out::println);
//        System.out.print("截取----------------------------------------------------\n");
//        Arrays.stream(age).limit(3).forEach(System.out::println);
//        System.out.print("跳过前几个元素-------------------------------------------------------\n");
//        Arrays.stream(age).skip(3).forEach(System.out::println);
//
//        System.out.print("--------------------------------映射-------------------------------------\n");
//        System.out.print("map-------------------------------------------------\n");
//        String[] arr = {"java", "scala", "php", "python", "c++"};
//        Arrays.stream(arr).map(String::toUpperCase).forEach(System.out::println);
//        System.out.print("mapToDouble----------------------------------------\n");
//        long[] array = {1, 4, 5, 6};
//        Arrays.stream(array).mapToDouble(e -> e * 200).forEach(System.out::println);
//        System.out.print("mapToInt--------------------------------------------\n");
//        Arrays.stream(array).mapToInt(e -> (int) (e + 1)).forEach(System.out::println);
//        System.out.print("多层遍历flatMap-------------------------------------------------\n");
//        List<List<String>> database = new ArrayList<>();
//        List<String> noSql = Arrays.asList("redis", "hbase", "membercache");
//        List<String> sql = Arrays.asList("mysql", "oracle", "db2");
//        database.add(noSql);
//        database.add(sql);
//        List<String> h = database.stream().flatMap(s -> s.stream().filter(si -> si.contains("s"))).collect(Collectors.toList());
//        h.stream().forEach(System.out::println);
//
//
//        // stream
//        DepartmentMapper departmentMapper = new DepartmentMapper();
//        // map 与 js 中一样 都是根据条件返回一个新的集合
//        System.out.print("实体类遍历1------------------------------------------------------------------\n");
//        departmentMapper.getDepartmentDataList().stream().map(e -> e.getDepartName()).forEach(System.out::println);
//        System.out.print("实体类遍历2--------------------------------------------------------------------\n");
//        departmentMapper.getDepartmentDataList().stream().map(Department::getDepartName).forEach(System.out::println);
        //

    }

}
